﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ViewModels="clr-namespace:MaxAlarm.ViewModels">
    
    <DataTemplate x:Key="OKButtonTemplate">
        <StackPanel Orientation="Horizontal">
            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.OKCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30"
                    IsDefault="True">
                <Button.Content>
                    <TextBlock Text="OK" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="OKCancelButtonTemplate">
        <StackPanel Orientation="Horizontal">
            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.OKCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30"
                    IsDefault="True">
                <Button.Content>
                    <TextBlock Text="OK" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.CancelCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30"
                    IsCancel="True">
                <Button.Content>
                    <TextBlock Text="Cancel" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="YesNoCancelButtonTemplate">
        <StackPanel Orientation="Horizontal">
            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.YesCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30"
                    IsDefault="True">
                <Button.Content>
                    <TextBlock Text="Yes" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.NoCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30">
                <Button.Content>
                    <TextBlock Text="No" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

            <Button Margin="10" 
                    Style="{StaticResource LoginButtons}"
                    Command="{x:Static ViewModels:MessageBoxViewModel.CancelCommand}"
                    Width="100"
                    Grid.Column="1"
                    Grid.Row="8"
                    HorizontalAlignment="Left"
                    Height="30"
                    IsCancel="True">
                <Button.Content>
                    <TextBlock Text="Cancel" 
                               Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="YesNoButtonTemplate">
        <StackPanel Orientation="Horizontal">
            <Button Margin="10" 
                        Style="{StaticResource LoginButtons}"
                        Command="{x:Static ViewModels:MessageBoxViewModel.YesCommand}"
                        Width="100"
                        Grid.Column="1"
                        Grid.Row="8"
                        HorizontalAlignment="Left"
                        Height="30"
                    IsDefault="True">
                <Button.Content>
                    <TextBlock Text="Yes" 
                                   Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>

            <Button Margin="10" 
                        Style="{StaticResource LoginButtons}"
                        Command="{x:Static ViewModels:MessageBoxViewModel.NoCommand}"
                        Width="100"
                        Grid.Column="1"
                        Grid.Row="8"
                        HorizontalAlignment="Left"
                        Height="30"
                        IsCancel="True">
                <Button.Content>
                    <TextBlock Text="No" 
                                   Style="{StaticResource BigWhite}"/>
                </Button.Content>
            </Button>
        </StackPanel>
    </DataTemplate>
    
    <DataTemplate x:Key="MessageBoxButtonsTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Canvas Grid.Row="0"
                    Grid.Column="0"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    Margin="10" 
                    x:Name="Icon"
                    Width="48"
                    Height="48"/>
            
            <TextBlock Text="{Binding Path=MessageText}"
                       Style="{StaticResource BigWhite}"
                       Grid.Row="0"
                       Grid.Column="1"
                       TextWrapping="Wrap"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Left" />
            
            <Canvas Background="{StaticResource LineBrush}"
				    Grid.ColumnSpan="2"
                    Grid.Row="0"
				    Height="1"
				    HorizontalAlignment="Stretch"
				    VerticalAlignment="Bottom"
				    Margin="2,0,2,0" />
            
            <ContentControl Content="{Binding}"
                            ContentTemplate="{x:Null}"
                            x:Name="Content"
                            Grid.Row="1"
                            Grid.ColumnSpan="2"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"/>

        </Grid>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=Buttons}" Value="OK">
                <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource OKButtonTemplate}" /> 
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=Buttons}" Value="OKCancel">
                <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource OKCancelButtonTemplate}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=Buttons}" Value="YesNo">
                <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource YesNoButtonTemplate}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=Buttons}" Value="YesNoCancel">
                <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource YesNoCancelButtonTemplate}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=MessageLevel}" Value="Question">
                <Setter TargetName="Icon" Property="Background" Value="{StaticResource QuestionIconBrush}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=MessageLevel}" Value="Info">
                <Setter TargetName="Icon" Property="Background" Value="{StaticResource InfoIconBrush}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=MessageLevel}" Value="Error">
                <Setter TargetName="Icon" Property="Background" Value="{StaticResource ErrorIconBrush}" />
            </DataTrigger>

            <DataTrigger Binding="{Binding Path=MessageLevel}" Value="Warning">
                <Setter TargetName="Icon" Property="Background" Value="{StaticResource WarningIconBrush}" />
            </DataTrigger>

        </DataTemplate.Triggers>
        
    </DataTemplate>

</ResourceDictionary>